package cn.yuanqiao.activiti.listener;

import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.TaskListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName: WritsArchiveBorrowListener
 * @Description: 类的描述
 * @author: lihuahua
 * @date: 2023/6/5 19:24
 * @Blog: huahuacoco.top
 */

@Component("SetNextAssigneeListener")
public class SetNextAssigneeListener implements TaskListener,ExecutionListener {

    @Autowired
    private TaskService taskService;

    @Override
    public void notify(DelegateTask task) {
        Object obj = task.getExecution().getVariable("nextAssignee");
        if (obj != null){
            taskService.setAssignee(task.getId(),String.valueOf(obj));

        }
    }

    @Override
    public void notify(DelegateExecution execution) {
        System.out.println(111);
        Map<String, Object> variables = execution.getVariables();
        String currentActivityId = execution.getCurrentActivityId();
        System.out.println(111);

    }

}
